package com.thinking.live.service.impl;

import com.thinking.live.entity.pojo.req.RechargeResultReq;
import com.thinking.live.enums.InformStateEnum;
import com.thinking.live.service.LiveChargeService;
import com.thinking.live.service.RechargeResultService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class RechargeResultServiceImpl implements RechargeResultService {

    @Autowired
    LiveChargeService liveChargeService;
    /**
     * 充值结果通知
     * @param request
     * @return
     */
    @Override
    public String inform(RechargeResultReq request) {
        log.info("充值结果通知:{}", request);
        switch (request.getState()) {
            case -1:
//                log.info("充值取消接口业务处理,充值状态：{}", request.getState());
                liveChargeService.refundChargeDataToThird(request.getOut_trade_num());
            case 2:
//                 log.info("huafeiisfailstatus：{}", request.getState());
                liveChargeService.refundChargeDataToThird(request.getOut_trade_num());
                return "success";
            case 1:
//                log.info("huafeiisokstatus：{}", request.getState());
                liveChargeService.doingChargeMoneyToThird(request.getOut_trade_num());
                return "success";
            case 3:
                /**
                 * 部分充值成功-进入人工通知阶段
                 */
//                    liveChargeService.doingChargeMoneyToThird(request.getOut_trade_num());
                return "success";
            default:
                log.info("huafeierrordata：{}", InformStateEnum.getName(0));
                return "success";
        }
    }
}
